﻿using System;
using CI.Organism;
using NUnit.Framework;

namespace Mesopotamia.UnitTests.Organism
{
    [TestFixture]
    public class MutationTests
    {

        /// <summary>
        /// calling mutate state with 0 percent chance of state mutation should return false
        /// </summary>
        [Test]
        public void MutateStateFalse()
        {
            Assert.IsFalse(Mutation.MutateState(0));
        }

        /// <summary>
        /// calling mutate state with 0 percent chance of state mutation should return false
        /// </summary>
        [Test]
        public void MutateStateTrue()
        {
            Assert.IsTrue(Mutation.MutateState(1));
        }

        /// <summary>
        /// calling mutate state with 0 percent chance of state mutation should return false
        /// </summary>
        [Test]
        public void RangeSelectTrue()
        {
            int _maxValue = 103;
            int _minValue = 100;
            int _result = Mutation.RangeSelect(_minValue, _maxValue);

            Assert.GreaterOrEqual(_maxValue, _result, "Not below the max value");
            Assert.LessOrEqual(_minValue, _result, "Not above the min value");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateUInt32()
        {
            Assert.AreNotEqual(Mutation.Mutate((UInt32)5, 1), 0, "result should not be 0");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateCrawlOrLeapUInt32()
        {
            Assert.AreNotEqual(Mutation.MutateCrawlOrLeap((UInt32)5, 1), 0, "result should not be 0");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateInt32()
        {
            Assert.AreNotEqual(Mutation.Mutate((Int32)5, 1), 0, "result should not be 0");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateCrawlOrLeapInt32()
        {
            Assert.AreNotEqual(Mutation.MutateCrawlOrLeap((Int32)5, 1), 0, "result should not be 0");
        }


        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateInt64()
        {
            Assert.AreNotEqual(Mutation.Mutate((Int64)5, 1), 0, "result should not be 0");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateCrawlOrLeapInt64()
        {
            Assert.AreNotEqual(Mutation.MutateCrawlOrLeap((Int64)5, 1), 0, "result should not be 0");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateDouble()
        {
            Assert.AreNotEqual(Mutation.Mutate((double)5, 1), 0, "result should not be 0");
        }

        /// <summary>
        /// Mutate a value, make sure we get a result
        /// </summary>
        [Test]
        public void MutateCrawlOrLeapDouble()
        {
            Assert.AreNotEqual(Mutation.MutateCrawlOrLeap((double)5, 1), 0, "result should not be 0");
        }

        [Test]
        public void Mutate5050()
        {
            var result = Mutation.Mutate5050();
        }
    }
}
